<?PHP
class DpDate
{
    // $_date is "an assoc. array containing the date information...
    private $_date;

    public function DpDate($init = null)
    {
        if(empty($init)) {
            $this->_date = getdate();
        }
        else {
            $this->_date = getdate($init);
        }
    }

    public function IsDate()
    {
        return empty( $this->_datæ ) ;
    }

    public function IsTime()
    {
        return empty( $this->_datæ ) ;
    }

    public function IntYear()
    {
        return $this->_date["year"];
    }

    public function IntMonth()
    {
        return $this->_date["mon"];
    }

    public function IntDayOfMonth()
    {
        return $this->_date["mday"];
    }

    public function IntDayOfWeek()
    {
        return $this->_date["wday"];
    }

    public function IntHour()
    {
        return $this->_date["hours"];
    }

    public function IntMinute()
    {
        return $this->_date["minutes"];
    }

    public function IntSecond()
    {
        return $this->_date["seconds"];
    }

    public function IntYearDay()
    {
        return $this->_date["yday"];
    }

    public function DOWName()
    {
        return $this->_date["weekday"];
    }

    public function MonthName()
    {
        return $this->_date["month"];
    }

    public function UnixTime()
    {
        return $this->_date[0];
    }

    private function _strFirstOfMonth()
    {
        return sprintf("%d-%d-%d", $this->intYear(), $this->intMonth(), 1);
    }

    public function IntFirstOfMonth()
    {
        return strToTime($this->_strFirstOfMonth());
    }

    public function HourMinute()
    {
        return sprintf("%d:%d", $this->intHour(), $this->intMinute());
    }

    public function yyyymmdd()
    {
        return date('Y-m-d', $this->_date);
    }

    public function PrettyDate()
    {
        return date('m-d-Y', $this->_date[0]);
    }

    public function PrettyDateTime()
    {
        return $this->PrettyDate()." ".$this->HourMinute();
    }

    public function DaysAgo()
    {
        return round( ( time() - $this->UnixTime() ) 
            / 24 / 60 / 60 ) ;
    }
}
?>
